package com.wxmp.wxcms.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.wxmp.wxcms.domain.RegisterUser;
import com.wxmp.wxcms.domain.RegisterUserType;
import com.wxmp.wxcms.mapper.RegisterUserDao;
import com.wxmp.wxcms.service.RegisterUserService;
@Service
public class RegisterUserServiceImpl implements RegisterUserService {
	@Resource
	private RegisterUserDao registerUserDao;
	@Override
	public RegisterUser getById(Integer id) {
		return registerUserDao.getById(id);
	}

	@Override
	public List<RegisterUser> getRegUserListByPage(RegisterUser searchEntity) {
		return registerUserDao.getRegUserListByPage(searchEntity);
	}

	@Override
	public void add(RegisterUser entity) {
		registerUserDao.add(entity);
	}

	@Override
	public void update(RegisterUser entity) {
		registerUserDao.update(entity);
	}

	@Override
	public void delete(RegisterUser entity) {
		registerUserDao.delete(entity);
	}

	@Override
	public Integer deleteBatchIds(String[] ids) {
		return registerUserDao.deleteBatchIds(ids);
	}

	@Override
	public int updateUseDay(Integer addDays, String openid) {
		return registerUserDao.updateUseDay(addDays, openid);
	}

	@Override
	public RegisterUser getRegisterUser(RegisterUser entity) {
		RegisterUser registerUser  = null;
		registerUser = registerUserDao.getRegisterUser(entity);
		if(registerUser!=null) {
			return registerUser;
		}else {
			return null;			
		}
	}


	@Override
	public List<RegisterUser> getRegUserByTypeByPage(RegisterUserType searchEntity) {
		return registerUserDao.getRegUserByTypeByPage(searchEntity);
	}

	@Override
	public boolean bindPhone(String openid) {
		String phone = registerUserDao.bindPhone(openid);
		if(phone !=null && !phone.equals(""))
			return  true;
		else 
			return false;
	}

	@Override
	public int updatePhone(RegisterUser entity) {
		return registerUserDao.updatePhone(entity);
	}

	@Override
	public RegisterUser getByOpenId(String openid) {
		return registerUserDao.getByOpenId(openid);
	}

	@Override
	public boolean userExists(String openid) {
		RegisterUser user =  registerUserDao.getByOpenId(openid);
		return user != null;
	}

}
